package org.dyk.seamanshousefrontdesk.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

//扩展SpirngMvc
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    /**
     * spring托管视图控制
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/index");
    }

    /**
     * 登录拦截
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new LoginHandlerInterceptor());
        //不允许放行的地址,拦截所有地址
        interceptorRegistration.addPathPatterns("/**");
        //允许放行的地址
        interceptorRegistration.excludePathPatterns("/login", "/checkLogin","/register", "/checkReqister",
                "/", "/index", "/proDetails","/assets/**");
    }
}
